// 统一管理用户相关的接口
import request from "@/utils/request";
import type { CreateSubjectForm, UploadWorkForm, ScheduleInfo } from "./type";
// 统一管理接口
enum API {
    GETLIST_URL = "/notNeed/subject/getSubjectList",
    GETMYLIST_URL = "/need/subject/getMySubjectList",
    CREATE_URL = "/need/subject/createSubject",
    GETINFO_URL = "/need/subject/getSubjectInfo",
    UPLOADWORK_URL = "/need/subject/uploadWork",
    SCHEDULEINFO_URL = "/need/subject/getScheduleInfo",
    ABORT_URL = "/need/subject/abortSubject",
    COMPLETE_URL = "/need/subject/completeSubject",
}

// 暴露请求函数
export const reqSubjectList = (data: searchParams) => {
    return request.post<any, ListResponseData<Subject>>(API.GETLIST_URL, data);
};
// 获取与我相关的课题列表
export const reqSubjectAboutMeList = (data: searchParams) => {
    return request.post<any, ListResponseData<Subject>>(API.GETMYLIST_URL, data);
};
// 申报课题
export const reqCreateSubject = (data: CreateSubjectForm) => {
    return request.post<any, ResponseData<{ subjectId: number }>>(API.CREATE_URL, data);
};
// 获取指定课题的信息
export const reqSubjectInfo = (data: { subjectId: number | string }) => {
    return request.post<any, ResponseData<Subject>>(API.GETINFO_URL, data);
};
// 提交项目进度
export const reqUploadWork = (data: UploadWorkForm) => {
    return request.post<any, ResponseData>(API.UPLOADWORK_URL, data);
};
// 获取进度详情
export const reqScheduleInfo = (data: { subject_id: number; schedule: number }) => {
    return request.post<any, ResponseData<ScheduleInfo | null>>(API.SCHEDULEINFO_URL, data);
};
// 终止课题
export const reqAbortSubject = (data: { id: number }) => request.post<any, ResponseData>(API.ABORT_URL, data);
// 完成课题
export const reqCompleteSubject = (data: { id: number }) => {
    return request.post<any, ResponseData>(API.COMPLETE_URL, data);
};
